FROM php:7.1-fpm

# -- timezone: default Asia/Shanghai
ARG timezone

# -- default value of args
ENV TZ=${timezone:-"Asia/Shanghai"}

# PECL Extensions Install
# 应该指定 Extension 版本
# ---- Unlike PHP core extensions, PECL extensions should be installed in series to fail properly if something went wrong.
# ---- Otherwise errors are just skipped by PECL.
# ---- For example, pecl install memcached-3.1.4 && pecl install redis-5.1.1 instead of pecl install memcached-3.1.4 redis-5.1.1.
# ---- However, docker-php-ext-enable memcached redis is fine to be all in one command.
RUN apt-get update && apt-get install -y zlib1g-dev apt-utils zip unzip\
   && pecl install redis-5.3.0 \
   && pecl install xlswriter-1.3.5 \
   && docker-php-ext-enable \
    xlswriter \
    redis


# PHP Extension installer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN install-php-extensions \
    mysqli \
    pdo_mysql \
    memcached \
    mongodb

# Timezone
RUN ln -sf /usr/share/zoneinfo/{$TZ} /etc/localtime \
    && echo ${TZ} > /etc/timezone

# Composer
RUN curl -sS https://getcomposer.org/installer | php \
    && mv composer.phar /usr/local/bin/composer \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/


